package com.dragon.modules.yuegou.service.impl.member;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dragon.modules.yuegou.entity.member.PtTurntablePrizeStoreEntity;
import com.dragon.modules.yuegou.mapper.member.PtTurntablePrizeStoreMapper;
import com.dragon.modules.yuegou.query.member.PtTurntablePrizeStoreQuery;
import com.dragon.modules.yuegou.service.member.PtTurntablePrizeStoreService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 大转盘奖品库存表 服务实现
 *
 * @author pbuilder generated
 * @date 2021-12-15 14:02:44
 * @version 2.0
 */
@Service("memPtTurntablePrizeStoreService")
public class PtTurntablePrizeStoreServiceImpl
		extends ServiceImpl<PtTurntablePrizeStoreMapper, PtTurntablePrizeStoreEntity>
		implements PtTurntablePrizeStoreService {

	@Override
	public void modifyStore(String turntableId, String prizeId,Integer changeCount) {
		PtTurntablePrizeStoreQuery query = new PtTurntablePrizeStoreQuery();
		query.setPrizeId(prizeId);
		query.setPointTurntableId(turntableId);
		query.setDel(false);
		List<PtTurntablePrizeStoreEntity> oldStore = this.list(query.toQueryWrapper());
		if (CollectionUtils.isNotEmpty(oldStore)){
			PtTurntablePrizeStoreEntity store = oldStore.get(0);

			baseMapper.modifyStore(store.getId(),store.getVersion(),changeCount);
		}
	}
}